#pragma once
#include <string>
namespace U41{
		struct node{
		node(std::string s, node* n, node* p){
			count = 1;
			word = s;
			next = n;
			previous = p;
		}

		void reset(){
			count = 1;
			word = "";
			next = nullptr;
			previous = nullptr;
		}

		void update(std::string s, node* n, node* p){
			count = 1;
			word = s;
			next = n;
			previous = p;
		}

		node* previous;
		int count;
		std::string word;
		node* next;
	};
		
		struct iterator{

		node *current, *next;
		iterator(node *n){
			if (n != nullptr){
				this->current = n;
				this->next = n->next;
			}
			else{
				this->current = n;
			}
		}
		bool hasNext(){
			if (next != nullptr){
				return true;
			}
			else{
				return false;
			}
		}
		void operator++(){
			{
				current = next;
				if (next != nullptr){
					next = current->next;
				}
			}
			
		}

		void operator++(int){{
				current = next;
				if (next != nullptr){
					next = current->next;
				}
			}
		}
		node* operator*(){
			return current;
		}

		bool operator== (iterator &fi){
			if (this->current == fi.current){
				return true;
			}
			return false;
		}
		bool operator!= (iterator &fi){
			return !(*this == fi);
		}
	};
	class UnorderedList
	{
	public:
		UnorderedList(void);
		UnorderedList(int size_free_list);
		~UnorderedList(void);
		void add(std::string s);
		void clear();
		void print();
		node* find(std::string s);
		node* getNode();
		void findMax();
		iterator begin(){
		return iterator(head);
		}
		iterator bottom(){

		return iterator(nullptr);
	}
		
	private:
		node* head;
		node* end;
		node* freehead;
		node* freeend;

		void addFree();
	};



	void main_one();
}
